package com.pearadmin.pro.modules.school.service.impl;

import java.util.List;
import java.util.ArrayList;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pearadmin.pro.common.web.base.page.PageResponse;
import com.pearadmin.pro.common.web.base.page.Pageable;

import com.pearadmin.pro.modules.school.domain.Contacts;
import com.pearadmin.pro.modules.school.domain.CourseBasicInformation;
import com.pearadmin.pro.modules.school.domain.TeachingMaterial;
import com.pearadmin.pro.modules.school.param.ContactsRequest;
import com.pearadmin.pro.modules.school.repository.ContactsRepository;
import com.pearadmin.pro.modules.school.service.ContactsService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * 学校联系人Service业务层处理
 *
 * @author ChenJian
 * @date 2021-08-29
 */
@Service
public class ContactsServiceImpl extends ServiceImpl<ContactsRepository, Contacts> implements ContactsService
{
    @Resource
    private ContactsRepository contactsRepository;

    /**
     * 查询学校联系人
     * @param request
     * @return 学校联系人 分页集合
     * */
    @Override
    public PageResponse<Contacts> page(ContactsRequest request)
    {
        LambdaQueryWrapper<Contacts> query = new LambdaQueryWrapper<Contacts>();
        query.eq(ObjectUtil.isNotEmpty(request.getContactsName()), Contacts::getContactsName,request.getContactsName());
        query.eq(ObjectUtil.isNotEmpty(request.getContactsPosition()), Contacts::getContactsPosition,request.getContactsPosition());
        query.eq(ObjectUtil.isNotEmpty(request.getResponsiblePerson()), Contacts::getResponsiblePerson,request.getResponsiblePerson());
        query.eq(ObjectUtil.isNotEmpty(request.getSchName()), Contacts::getSchName,request.getSchName());
        query.eq(ObjectUtil.isNotEmpty(request.getContactsState()), Contacts::getContactsState,request.getContactsState());
        return Pageable.of(request,(()->  contactsRepository.selectList(query)));
    }

    /**
     * 查询学校联系人
     *
     * @param id 学校联系人ID
     * @return 学校联系人
     */
    @Override
    public Contacts selectContactsById(Long id)
    {
        return contactsRepository.selectById(id);
    }

}
